package com.atguigu.ssm.service.impl;

import com.atguigu.ssm.mapper.DeptMapper;
import com.atguigu.ssm.pojo.Dept;
import com.atguigu.ssm.service.DeptService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author
 * @create 2021/10/25 14:51
 */
@Service("deptService")
public class DeptServiceImpl implements DeptService {



    @Autowired
//    @Qualifier("detpMapper")
    private DeptMapper deptMapper;

    @Override
    public List<Dept> getAllDepts() {
        System.out.println("DeptServiceImpl####");
        List<Dept> depts = deptMapper.selectAllDepts();
        return depts;
    }

    @Override
    @Transactional
    public void addDept(Dept dept) {
        deptMapper.insertDept(dept);
    }

    @Override
    public void delete(Integer deptId) {

        deptMapper.deleteById(deptId);
    }

    @Override
    public Dept getDeptById(Integer deptId) {
        return deptMapper.getDeptById(deptId);
    }

    @Override
    public void handleUpdate(Dept dept) {
        deptMapper.update(dept);
    }
}
